export interface IMatchItem {
  gameId: string;
  championId: string;
  isWin: string;
  kills: number;
  deaths: number;
  assists: number;
  matchTime: string;
  gameModel: string;
}
export class MatchItem implements IMatchItem {
  gameId: string;
  championId: string;
  isWin: string;
  kills: number;
  deaths: number;
  assists: number;
  matchTime: string;
  gameModel: string;
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  constructor(data: any) {
    this.gameId = data.gameId;
    this.championId = `https://raw.communitydragon.org/latest/plugins/rcp-be-lol-game-data/global/default/v1/champion-icons/${data.participants[0].championId}.png`;
    this.isWin = data.participants[0].stats.win;
    this.kills = data.participants[0].stats.kills;
    this.deaths = data.participants[0].stats.deaths;
    this.assists = data.participants[0].stats.assists;
    this.matchTime = formatDate(data.gameCreation);
    this.gameModel = querGameType(data.queueId);
  }
}
function formatDate(gameCreation: number): string {
  const date = new Date(gameCreation);
  const month = String(date.getMonth() + 1).padStart(2, "0"); // 获取月份并补零
  const day = String(date.getDate()).padStart(2, "0"); // 获取日期并补零
  return `${month}-${day}`;
}

export const querGameType = (queueId: number) => {
  switch (queueId) {
    case 420:
      return "单双排";
    case 430:
      return "匹配赛";
    case 440:
      return "灵活排位";
    case 450:
      return "大乱斗";
    case 1700:
      return "斗魂竞技场";
  }
  return "其他模式";
};
